<template>
	<template v-if="dataSource.contractType === 2">
		<a-descriptions title="承租企业" :column="3" class="ant-descriptions-blockquote">
			<a-descriptions-item label="承租企业信息">
				{{ dataSource.enterRenterInfo?.name }}/{{ dataSource.enterRenterInfo?.phone }}
			</a-descriptions-item>
			<a-descriptions-item label="合作周期">
				{{ dataSource.enterPriseDTO?.beginTime }} - {{ dataSource.enterPriseDTO?.endTime }}
			</a-descriptions-item>

			<!-- <a-descriptions-item label="协议优惠方案">
				{{ dataSource.enterPriseDTO?.enterPriseTeamWordDetailsName }} /
				{{ dataSource.enterPriseDTO?.type === 1 ? '折扣' : '减免' }} /{{ discountTypeMap[dataSource.enterPriseDTO?.discountType]
				}}{{ dataSource.enterPriseDTO?.discountScale }}%
			</a-descriptions-item> -->
			<a-descriptions-item label="企业联系人">
				{{ dataSource.enterRenterInfo?.emergencyName }}/{{ dataSource.enterRenterInfo?.emergencyPhone }}/{{
					dataSource.enterPriseDTO?.linkmanPost
				}}
			</a-descriptions-item>
		</a-descriptions>
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
	</template>

	<a-descriptions size="small">
		<template #title>
			<div class="d-module-title">
				<b>房源信息</b>
				<a-tag :color="dataSource.statusInfo.color" style="margin-left: 10px">{{ dataSource.statusInfo.name }}</a-tag>
			</div>
		</template>
		<a-descriptions-item label="房屋户型">{{ dataSource.house.layoutInfo }}</a-descriptions-item>
		<a-descriptions-item label="房屋面积">{{ dataSource.house.area || '' }}㎡</a-descriptions-item>
		<a-descriptions-item label="楼层信息">
			第
			{{ dataSource.house.currentFloor }}
			层，共
			{{ dataSource.house.totalFloor }}
			层
		</a-descriptions-item>
		<a-descriptions-item label="房源地址">{{ dataSource.house.houseAddress }}</a-descriptions-item>
		<a-descriptions-item label="可住人数">{{ dataSource.house.userlimit || '-' }} 人</a-descriptions-item>
	</a-descriptions>
	<template v-if="[11, 42].includes(dataSource.contractStatus)">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>意向信息</b>
				</div>
			</template>
			<a-descriptions-item label="承租价格">{{ dataSource.price }}元/{{dataSource.contractRentType === 2? '日':'月'}}</a-descriptions-item>
			<a-descriptions-item label="押金">{{ dataSource.deposit }}元</a-descriptions-item>
			<a-descriptions-item label="付款方式">
				<span>押{{ dataSource.depositMonth }}</span>
				<span v-if="dataSource.periodMonth === 99">一次性付</span>
				<span v-else>付{{ dataSource.periodMonth }}</span>
			</a-descriptions-item>
			<a-descriptions-item label="合同周期">
				{{ formatDate(dataSource.beginTime) }}至{{ formatDate(dataSource.endTime) }}
			</a-descriptions-item>
		</a-descriptions>
	</template>
	<template v-if="![11, 42].includes(dataSource.contractStatus)">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>合同信息</b>
					<!-- v-action=['mk_contract_tenant_bjhtxx'] -->
					<!-- 审批中和作废不展示 -->
					<a
						v-if="![1, '1'].includes(props.approvalStatus as number) && ![41,42].includes(dataSource.contractStatus) && hasPermissions(['mk_contract_tenant_bjhtxx'])"
						@click.stop="visibles.updateContract = true">
						<FormOutlined class="update-icon" />
						<a class="update-information">编辑合同信息</a>
					</a>
				</div>
			</template>
			<a-descriptions-item label="合同编号">{{ dataSource.contractNo }}</a-descriptions-item>
			<a-descriptions-item label="签约类型">
				<a-space>
					{{ dataSource.contractMedium === 1 ? '纸质' : '电子' }}
					<a
						class="download-code-text"
						v-if="dataSource.contractMedium === 2 && previewUrl"
						@click="preview"
						download="电子合同.pdf">
						预览
					</a>
					<a
						class="download-code-text"
						v-if="dataSource.contractMedium === 2 && previewUrl && dataSource.authType === 1"
						:href="downloadUrl"
						target="_blank"
						download="电子合同.pdf">
						下载
					</a>
					<a
						class="download-code-text"
						v-if="dataSource.contractMedium === 2 && dataSource.authType === 2  && dataSource.signStatus === 2"
						@click="getBestSignFile('contract')"
						target="_blank"
						download="电子合同.pdf">
						下载
					</a>
				</a-space>
			</a-descriptions-item>
			<a-descriptions-item label="合同类型">
				<span v-if="dataSource.contractType === 1">个人合同</span>
				<span v-if="dataSource.contractType === 2">
					企业合同{{ dataSource.additional === 2 ? '-补签合同' : dataSource.signType === 4 ? '-换房合同' : '' }}
				</span>
				<span v-if="dataSource.contractType === 4">企业合同-框架协议</span>
			</a-descriptions-item>
			<a-descriptions-item label="成交方式">{{ signType[dataSource.signType] }}</a-descriptions-item>
			<a-descriptions-item label="合同周期">
				{{ formatDate(dataSource.beginTime) }}至{{ formatDate(dataSource.endTime) }}
			</a-descriptions-item>
			<a-descriptions-item label="承租价格">{{ dataSource.price || 0 }}元/{{dataSource.contractRentType === 2? '日':'月'}}</a-descriptions-item>
			<a-descriptions-item label="押金">{{ dataSource.deposit }}元</a-descriptions-item>
			<a-descriptions-item label="付款方式">
				<span>押{{ dataSource.depositMonth }}</span>
				<span v-if="dataSource.periodMonth === 99">一次性付</span>
				<span v-else>付{{ dataSource.periodMonth }}</span>
			</a-descriptions-item>
			<a-descriptions-item label="收租日设置">
				<template v-if="dataSource.payPattern === 1">提前{{ dataSource.payPatternValue }}天收租</template>
				<template v-else-if="dataSource.payPattern === 2">固定{{ dataSource.payPatternValue }}号收租(每期第一个月)</template>
				<template v-else>固定{{ dataSource.payPatternValue }}号收租(每期提前一个月)</template>
			</a-descriptions-item>
			<a-descriptions-item label="录入时间">{{ dataSource.createTime }}</a-descriptions-item>
			<a-descriptions-item label="免租期天数">
				<template v-if="dataSource.rentFreeDay > 0">
					{{ dataSource.rentFreeDay }}天（{{ dataSource.rentFreeBeginTime }} 至 {{ dataSource.rentFreeEndTime }}）
				</template>
				<template v-else>-</template>
			</a-descriptions-item>
			<a-descriptions-item label="补充说明">{{ dataSource.addExplanation || '-' }}</a-descriptions-item>
			<a-descriptions-item label="合同附件">
				<a @click="visibles.upload = true">查看附件</a>
				<!--<file-preview :biz-id="dataSource.id" />-->
			</a-descriptions-item>
		</a-descriptions>
	</template>

	<!-- 企业框架合同 -->
	<template v-if="dataSource.contractType === 4">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions title="关联企业信息" :column="3" class="ant-descriptions-blockquote">
			<a-descriptions-item label="企业">{{ enterPriseInfo.enterPriseName }}</a-descriptions-item>

			<a-descriptions-item label="统一社会信用代码">{{ enterPriseInfo.societyCode }}</a-descriptions-item>

			<a-descriptions-item label="合作周期">{{ enterPriseInfo.beginTime }} - {{ enterPriseInfo.endTime }}</a-descriptions-item>

			<a-descriptions-item label="协议优惠方案" :span="4">
				<a-descriptions
					v-if="discountsInfo?.protocolDiscounts?.length"
					size="small"
					colon
					bordered
					:column="4"
					class="discount-descriptions">
					<template v-for="item in discountsInfo.protocolDiscounts || []" :key="item.discount.id">
						<a-descriptions-item label="优惠名称" :span="item.discount.id === '-1' ? 3 : 1">
							<a-typography-text :content="item.discount.discountName" :ellipsis="{tooltip: true}" style="width: 200px" />
						</a-descriptions-item>
						<template v-if="item.discount.id !== '-1'">
							<a-descriptions-item label="优惠有效期">
								{{ item.discount.beginTime || '-' }} ~ {{ item.discount.endTime || '-' }}
							</a-descriptions-item>
							<a-descriptions-item label="优惠方案">
								{{ discountTypeMap[item.discount.discountType] }} 、 {{ item.discount.discountScale }}% 、
								{{ item.discount.feeSubjects.map(o => o.name).join('/') }} 、
								{{ item.discount.stackable ? '可叠加' : '不可叠加' }}
							</a-descriptions-item>
						</template>
						<a-descriptions-item label="成交方式">
							{{ SIGN_TYPE_MAP[item.discount.signType] || '新签' }}
						</a-descriptions-item>
					</template>
				</a-descriptions>
				<template v-else>无优惠</template>
			</a-descriptions-item>
		</a-descriptions>
		<!-- <a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" /> -->
	</template>

	<!-- 待处理 隐藏模块 -->
	<template v-if="dataSource.contractType !== 2">
		<template v-if="![11].includes(dataSource.contractStatus)">
			<template v-if="(dataSource.renterContractSupplementDTOList || []).length">
				<template v-for="(item, index) in dataSource.renterContractSupplementDTOList || []" :key="index">
					<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
					<a-descriptions size="small">
						<template #title>
							<div class="d-module-title">
								<b>补充合同</b>
								<!-- 有补充合同 -->

								<!-- 有补充合同没有签字 -->
								<template
									v-if="
										[12, 18, 21, 23, 24, 25, 26, 27].includes(dataSource.contractStatus) &&
										[1].includes(item.signStatus) &&
										item.authType === 1
									">
									<a-tag color="warning" style="margin-left: 10px">{{ supplementSignType[item.signStatus] }}</a-tag>
									<a v-action="['mk_contract_tenant_yqbchtqz']" @click="inviteUser(item)">邀请签字</a>
								</template>

								<template v-else>
									<!-- 有补充合同已经签字 -->
									<a-tag color="green" style="margin-left: 10px">{{ supplementSignType[item.signStatus] }}</a-tag>
									<!-- 退租和无效情况 如果签字可以查看和下载 没签字就隐藏入口 -->
									<template v-if="2 === item.signStatus">
										<a style="margin: 0px 5px" @click="preview('supplement')">预览</a>
										<a :href="supplementDownloadUrl" v-if="dataSource.authType === 1" target="_blank" download="补充合同.pdf">下载</a>
										<a
											v-if="dataSource.authType === 2"
											@click="getBestSignFile('supplement')"
											target="_blank"
											download="电子合同.pdf">
											下载
										</a>
									</template>
								</template>
							</div>
						</template>
						<a-descriptions-item label="合同编号">{{ item.supplementNo }}</a-descriptions-item>
						<a-descriptions-item label="合同周期">
							{{ formatDate(item.beginTime) }} - {{ formatDate(item.endTime) }}
						</a-descriptions-item>
					</a-descriptions>
				</template>
			</template>
			<template v-else>
				<template v-if="[12, 18, 21, 23, 24, 25, 26, 27].includes(dataSource.contractStatus)">
					<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
					<a-descriptions size="small">
						<template #title>
							<div class="d-module-title">
								<b>补充合同</b>
								<!-- 没有补充合同 -->
								<a v-if="![1, '1',2,'2',4,'4'].includes(props.approvalStatus as number)">
									<plus-circle-outlined
										v-action="['mk_contract_tenant_tjbcht']"
										@click="addSupplementContract"
										style="margin-left: 5px" />
								</a>
							</div>
						</template>
						<template v-for="(item, index) in dataSource.renterContractSupplementDTOList || []" :key="index">
							<a-descriptions-item label="合同编号">{{ item.supplementNo }}</a-descriptions-item>
							<a-descriptions-item label="合同周期">{{ item.begintime }} - {{ item.endtime }}</a-descriptions-item>
						</template>
					</a-descriptions>
				</template>
			</template>
		</template>
	</template>
	<template v-for="item in discountDTOList" :key="item.id">
		<!-- item.type 【1-立减、2-折扣、3-优惠券、4-付款优惠】 -->
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>优惠信息（{{ item.type === 4 ? '付款优惠' : '优惠活动' }}）</b>
				</div>
			</template>
			<a-descriptions-item label="活动主题">{{ item.name }}</a-descriptions-item>
			<template v-if="item.type === 1">
				<a-descriptions-item label="活动形式">立减</a-descriptions-item>
				<a-descriptions-item label="租金减免">{{ item.discountAmount }}元</a-descriptions-item>
			</template>
			<template v-else-if="item.type === 2">
				<a-descriptions-item label="活动形式">折扣</a-descriptions-item>
				<a-descriptions-item label="租金折扣">{{ item.discountAmount }}%</a-descriptions-item>
			</template>
			<a-descriptions-item v-else label="签约租期">&ge;{{ item.useThreshold }}个月</a-descriptions-item>
			<a-descriptions-item label="活动期限">{{ item.startDate.split(' ')[0] }}至{{ item.endDate.split(' ')[0] }}</a-descriptions-item>
			<!--  付款优惠 展示字段-->
			<template v-if="item.type === 4">
				<a-descriptions-item label="季付">{{ item.payDiscountDto.quarterlyPayment }} %</a-descriptions-item>
				<a-descriptions-item label="半年付">{{ item.payDiscountDto.semiAnnualPayment }} %</a-descriptions-item>
				<a-descriptions-item label="年付">{{ item.payDiscountDto.annualPayment }} %</a-descriptions-item>
			</template>
			<!-- 优惠活动 展示字段  -->
			<template v-else>
				<a-descriptions-item label="签约类型">{{ activitySignType[item.signType] || '不限制' }}</a-descriptions-item>
				<a-descriptions-item label="签约租期">&ge;{{ item.useThreshold }}个月</a-descriptions-item>
			</template>
			<a-descriptions-item label="活动详情">
				<a @click="openActivityDetail(item)">查看详情</a>
			</a-descriptions-item>
			<a-descriptions-item v-if="item.type !== 4" label="时间段">
				{{
					item?.detailedTimePeriod === 0
						? '租期内'
						: item.detailedTimePeriod > 0
						? `后${Math.abs(item.detailedTimePeriod)}个月`
						: `前${Math.abs(item.detailedTimePeriod)}个月` || ''
				}}
			</a-descriptions-item>
			<!-- <a-descriptions-item label="操作时间" :span="2">{{ dataSource.createTime }}</a-descriptions-item> -->
			<a-descriptions-item label="备注" :span="5">{{ item.remark }}</a-descriptions-item>
		</a-descriptions>
	</template>
	<template v-if="![11, 42].includes(dataSource.contractStatus)">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>签约信息</b>
				</div>
			</template>
			<a-descriptions-item label="签约部门">{{ dataSource.signDeptName }}</a-descriptions-item>
			<a-descriptions-item label="签约人">{{ dataSource.signEmpName }}</a-descriptions-item>
			<a-descriptions-item label="合同维护人">{{ dataSource.maintainerName }}</a-descriptions-item>
			<a-descriptions-item label="签约时间">{{ formatDate(dataSource.signTime) }}</a-descriptions-item>
		</a-descriptions>
	</template>

	<template v-if="[31, 32, 33].includes(dataSource.contractStatus) && dataSource.cancelInfo">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>退租信息</b>
				</div>
			</template>
			<a-descriptions-item label="退租日期" :span="1">{{ formatDate(dataSource.quiteDate) }}</a-descriptions-item>
			<a-descriptions-item label="处理人" :span="1">{{ dataSource.cancelInfo.rejectName }}</a-descriptions-item>
			<a-descriptions-item label="处理时间" :span="1">{{ dataSource.cancelInfo.rejectTime }}</a-descriptions-item>
			<a-descriptions-item label="退租原因" :span="3">{{ dataSource.cancelInfo.reason }}</a-descriptions-item>
		</a-descriptions>
	</template>
	<template v-if="[42].includes(dataSource.contractStatus) && dataSource.rejectReason">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>拒绝信息</b>
				</div>
			</template>
			<a-descriptions-item label="拒绝人">{{ dataSource.rejectReason.rejectName }}</a-descriptions-item>
			<a-descriptions-item label="拒绝时间">{{ dataSource.rejectReason.rejectTime }}</a-descriptions-item>
			<a-descriptions-item label="拒绝原因">{{ dataSource.rejectReason.reason }}</a-descriptions-item>
		</a-descriptions>
	</template>
	<template v-if="[41].includes(dataSource.contractStatus) && dataSource.rejectReason">
		<a-divider type="horizontal" style="background-color: #f5f5f5; margin: 20px 0" />
		<a-descriptions size="small">
			<template #title>
				<div class="d-module-title">
					<b>作废信息</b>
				</div>
			</template>
			<a-descriptions-item label="作废人">
				{{ dataSource.rejectReason.rejectName + '-' + dataSource.rejectReason.rejectPhone }}
			</a-descriptions-item>
			<a-descriptions-item label="作废时间">{{ dataSource.rejectReason.rejectTime }}</a-descriptions-item>
			<a-descriptions-item label="作废原因">{{ dataSource.rejectReason.reason }}</a-descriptions-item>
		</a-descriptions>
	</template>
	<file-upload-dialog
		v-model:visible="visibles.upload"
		:biz-id="dataSource.id"
		:isDetails="[1, '1',2,'2',4,'4'].includes(props.approvalStatus as number)" />

	<add-supplement-dialog v-model:visible="visibles.addSupplement" :dataSource="dataSource" @success="emits('success')" />
	<copy-url v-model:visible="visibles.showCopyUrl" :url="supplementSignUrl" />
	<!--修改合同信息 -->
	<update-contract v-model:visible="visibles.updateContract" :dataSource="props.dataSource" @success="emits('close')"></update-contract>
</template>

<script setup lang="ts">
	import {reactive, ref, createVNode, onMounted} from 'vue'
	import FileUploadDialog from '@/components/common/file-upload-dialog.vue'
	import {formatDate} from 'yuxin-base/src/utils/date'
	import {
		signPreviewUrl,
		signFileDownloadUrl,
		getSupplementExecuteUrl,
		getSupplementPreview,
		supplement_sign_file_stream,
		sign_file_stream,
		downloadSupplement,
		getEnterPriseInfo,
		discounts
	} from '@/api/contract'
	import {discountTypeMap} from '@/constant/enterprise-customers'
	import dialogs from '@/micros/dialogs'
	import addSupplementDialog from './add-supplement-contract.vue'
	import {PlusCircleOutlined, ExclamationCircleOutlined, FormOutlined} from '@ant-design/icons-vue'
	import UpdateContract from '@/components/contract/contract-detail-dialog/tenant/update-contract.vue'
	import {Modal} from 'ant-design-vue'
	import {useStore} from '@/store/index'
	import CopyUrl from './copy-url.vue'
	import {SIGN_TYPE_MAP} from '@/interface/contract'

	const emits = defineEmits(['success', 'close'])

	const hasPermissions = useStore().hasPermissions

	const props = defineProps<{
		dataSource: any
		approvalStatus?: number | null | string
	}>()

	const visibles = reactive({
		upload: false,
		addSupplement: false,
		showCopyUrl: false,
		// 编辑合同信息
		updateContract: false
	})
	const isDetails = ref(false)
	const preview = isSupplement => {
		const {authType} = props.dataSource
		const isBestSign = authType === 2

		if ('supplement' === isSupplement) {
			window.open(supplementPreviewUrl.value, '_blank')
		} else {
			window.open(previewUrl.value, '_blank')
		}
	}
	const previewUrl = ref('')
	const supplementPreviewUrl = ref('')

	/** 企业框架信息 */
	const enterPriseInfo = ref<any>({})
	/** 框架合同优惠信息 */
	const discountsInfo = ref<any>({})

	/** 优惠信息 */
	const discountDTOList = ref<any>([])

	const getSignPreviewUrl = () => {
		const {authType} = props.dataSource
		const isBestSign = authType === 2
		signPreviewUrl({clientType: 'PC', signChannel: isBestSign ? 2 : 1, contractId: props.dataSource.id}).then(res => {
			previewUrl.value = res.data
		})
	}
	// 获取补充合同预览
	const getSupplementPreviewUrl = () => {
		const {authType} = props.dataSource
		const isBestSign = authType === 2
		getSupplementPreview({
			clientType: 'PC',
			contractId: props.dataSource.id,
			signChannel: isBestSign ? 2 : 1,
			supplementId: props.dataSource.renterContractSupplementDTOList[0].id
		}).then(res => {
			supplementPreviewUrl.value = res.data
		})
	}
	const getBestSignFile = async (type: 'supplement' | 'contract') => {
		const {id, renterContractSupplementDTOList=[], authType} = props.dataSource
		if (authType === 1) return
		const supplementId = (renterContractSupplementDTOList ||[])[0]?.id
		const MapAdaptor = new Map([
			[
				'supplement',
				{
					api: supplement_sign_file_stream,
					params: supplementId,
					fileName: '补充合同.pdf'
				}
			],
			[
				'contract',
				{
					api: sign_file_stream,
					params: id,
					fileName: '电子合同.pdf'
				}
			]
		])
		const {api, params, fileName} = MapAdaptor.get(type)
		console.log(api, params)
		await api(params).then((res: any) => {
			const blob = new Blob([res], {
				type: 'application/pdf;charset=utf-8'
			})

			const link = document.createElement('a')
			link.href = window.URL.createObjectURL(blob)
			link.download = fileName
			link.click()
		})
	}
	const downloadUrl = ref('')
	const supplementDownloadUrl = ref('')
	const supplementSignUrl = ref('')
	const getSignFileDownloadUrl = () => {
		signFileDownloadUrl(props.dataSource.id).then(res => {
			downloadUrl.value = res.data[0]
		})
	}
	const getSupplementDownloadUrl = () => {
		downloadSupplement(props.dataSource.renterContractSupplementDTOList[0].id).then(res => {
			supplementDownloadUrl.value = res.data[0]
		})
	}
	onMounted(() => {
		if (props.dataSource.id && props.dataSource.contractMedium === 2 && props.dataSource?.econtractModelId) {
			getSignPreviewUrl()
			getSignFileDownloadUrl()
		}
		if (
			props.dataSource.id &&
			props.dataSource.renterContractSupplementDTOList &&
			props.dataSource.renterContractSupplementDTOList.length
		) {
			const isBestSign = props.dataSource.authType === 2 &&  (props.dataSource.renterContractSupplementDTOList ||[]).some(e=>e.signStatus === 2)
			const shouldRender = props.dataSource.authType !== 2 ||  isBestSign
			shouldRender && getSupplementPreviewUrl()
			shouldRender && getSupplementDownloadUrl()
		}

		// 企业框架协议 获取企业信息
		if (props.dataSource.contractType === 4) {
			getEnterPriseInfo
			getEnterPrise()
		}

		getDiscounts()
	})
	const signType: {
		[key: string | number]: any
	} = {1: '新签', 2: '续签', 3: '转租', 4: '换房', 5: '补签'}
	const activitySignType: {
		[key: string | number]: any
	} = {null: '不限制', 1: '仅新签', 2: '仅续签'}

	const supplementSignType = {
		0: '未实名',
		1: '待签字',
		2: '已签约'
	}
	// 打开详情
	const openActivityDetail = (item: any) => {
		const {type: approvalType, id: businessId} = item
		if (item.type === 4) {
			// 付款优惠详情
			dialogs.showActivityDeatailDialog('付款优惠', '/payment-preference/detail', {approvalType, businessId})
		} else if (item.type !== 3) {
			// 优惠活动详情
			dialogs.showActivityDeatailDialog('优惠活动', '/preferential-activities/detail', {approvalType, businessId})
		}
	}
	// 添加补充详情
	const addSupplementContract = () => {
		visibles.addSupplement = true
	}
	// 邀请签字
	const inviteUser = row => {
		Modal.confirm({
			title: '邀请签字',
			centered: true,
			icon: createVNode(ExclamationCircleOutlined),
			content: `是否邀请【${props.dataSource.renterInfo.name}/${props.dataSource.renterInfo.phone}】进行签字`,
			onOk() {
				getSupplementExecuteUrl({
					clientType: 'H5',
					contractId: props.dataSource.id,
					contractType: 3,
					signerPhone: props.dataSource.renterInfo.phone,
					supplementId: props.dataSource.renterContractSupplementDTOList[0].id
				}).then(res => {
					supplementSignUrl.value = res.data?.url || ''
					visibles.showCopyUrl = true
				})
			}
		})
	}

	/** 获取企业框架合同相关信息 */
	const getEnterPrise = async () => {
		getEnterPriseInfo({
			enterPriseId: props.dataSource.enterPriseId
		}).then(res => {
			enterPriseInfo.value = res.data
		})

		discounts({
			contractId: props.dataSource.id
		}).then(res => {
			discountsInfo.value = res.data
		})
	}

	/** 查询是否有优惠 */
	const getDiscounts = () => {
		discounts({
			contractId: props.dataSource.id
		}).then(res => {
			discountDTOList.value = res.data.activityDiscounts || []
		})
	}
</script>

<style lang="less" scoped>
	:deep(.ant-descriptions-item-label) {
		color: rgba(0, 0, 0, 0.45);
	}
	.update-icon {
		margin-left: 10px;
	}
	.update-information {
		margin: 3px 0 0 3px;
		font-size: 13px;
	}

	.discount-descriptions {
		:deep .ant-descriptions-row {
			th,
			td {
				font-size: 12px;
				padding: 4px 8px;
			}
		}
	}
</style>
